package com.zxl.register.server.command;

import com.zxl.register.base.Event;
import com.zxl.register.base.Result;
import com.zxl.register.server.core.ServiceRegistCore;
import lombok.Data;

import java.io.IOException;

@Data
public class HeartBeatHandler extends CommandHandler {


    @Override
    public String getKey() {
        this.key="heartbeat";
        return key;
    }

    @Override
    public Result handle(Event event) {
        try {
            ServiceRegistCore.processHeartBeat(event.getInstance().getSocketChannel().getRemoteAddress().toString());
        } catch (IOException e) {
            e.printStackTrace();
            System.err.println(" process heartbeat fail! event : "+event);
        }
        return null;
    }
}
